﻿@model Inscriptionem.Models.Blog.Base.BaseViewModel

@{Html.RenderPartial("Controls/Buttons");}
<div class="sidebaradbox"></div>

<ul>
@if (Model.Categories.Any())
{
<text>
<li id="recent-posts">
    <h2>Popular posts</h2>
    <ul style="list-style:none;">
        @foreach (var post in Model.Categories.SelectMany(c => c.PostCategories).Select(pc => pc.Post).Where(p => p.IsPublished).Distinct().OrderByDescending(c => c.ViewCount).Take(5))
        { 
        <text>
        <li>
            <span style="padding-top:0px; float:left;">
                <a style="float:left; font-weight:bold; padding-top:5px;" title="Post: @post.Title" href="/@Model.Language/@Model.Section/Post/@post.ID">@post.Title</a>
                <br /><br />
                @(Inscriptionem.Extensions.StringExtensions.StripHTML(post.Content.Length > 125 ? post.Content.Substring(0, 125) : post.Content)) [...]
            </span>
            <div class="clear"></div>
        </li>
        </text>
        }
    </ul>
</li>
</text>
}

@if (Model.Categories.Any())
{
<text>
<li id="categories-right" class="widget widget_categories">
    <h2 class="widgettitle">Archive</h2>
    @{Html.RenderPartial("Controls/ArchiveMenu", new Inscriptionem.Models.Blog.Views.Controls.ArchiveMenuViewModel(Model));}
</li>
</text>
}

@{Html.RenderPartial("Controls/MemberMenu", Model);}
</ul>